package com.example.java14;

public class TestInstanceof {

    public static void main(String[] args){

        // 14之前
        Object name = "千江镇";
        if(name instanceof String){
            String str = (String) name;
            System.out.println(str);
        }

        // 14之后, 如果类型匹配，直接把name赋值给str
        if(name instanceof String str){
            System.out.println(str);
        }

    }

}
